package gao.xiaolei.dao;

import gao.xiaolei.entity.TestDesign;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

@Repository("TestDesignDao")
public interface TestDesignDao extends JpaRepository<TestDesign, String>,TreeMethod<TestDesign> {


    // 获取该节点的子节点数量（自己写的或则别人审核通过的或者是文件夹）
    @Query(value = "select count(*) from TestDesign where parentId = :id and(author=:userId or status=3 or leaf=0)")
    public Integer getChildrenCount(@Param("id") String id,
                                    @Param("userId") String userId);

    // 获取测试计划的项目
    @Query(value = "select project from TestDesign where id=:id")
    public String getProject(@Param("id") String id);
}
